package cn.highedu.spring;

/**
 * 单例模式演示
 */
public class SingletonTest {
    public static void main(String[] args) {
        // girl对象只能有一个
        Girl girl = Girl.getInstance();
        Girl girl1 = Girl.getInstance();
        System.out.println(girl == girl1);
    }
}

/**
 * 单例模式
 */
class Girl{
    private static Girl instance = new Girl();

    private Girl(){
    }

    public static Girl getInstance() {
        return instance;
    }
}
